<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<div style="text-align: center;">
    <h1 >登录</h1>
    用户：<input type="text" id="username"><br>
    密码：<input type="password" id="password"><br>
    <button style="margin-top:20px;margin-left: 50px;">登录</button>
</div>

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
    let btn=document.querySelector('button');
    btn.onclick=function () {
        let inputs=document.querySelectorAll('input');
        let username=inputs[0].value;
        let password=inputs[1].value;
        $.ajax({
            method:'get',
            url:'/login/index'+location.search,
            data:JSON.stringify({username:username,password:password}),
            contentType:'application/json;charset=utf8',
            success:function (body) {
                console.log(body)
                alert(body.msg)
            }
        });
    }
</script>
</body>
</html>